package com.mdlaser.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

/**
 * @author 朱艺超
 * @version 2022.0907
 */

@Configuration
public class ScheduledConfig {
  Logger logger = LoggerFactory.getLogger(getClass());
  @Bean
  public ThreadPoolTaskScheduler threadPoolTaskScheduler() {
    logger.info("创建定时任务调度线程池 start");
    ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler();
    threadPoolTaskScheduler.setPoolSize(20);
    threadPoolTaskScheduler.setThreadNamePrefix("taskExecutor-");
    threadPoolTaskScheduler.setWaitForTasksToCompleteOnShutdown(true);
    threadPoolTaskScheduler.setAwaitTerminationSeconds(60);
    logger.info("创建定时任务调度线程池 end");
    return threadPoolTaskScheduler;
  }

}
